package cn.hp.service.impl;

import cn.hp.mapper.MenuMapper;
import cn.hp.entity.Menu;
import cn.hp.service.MenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Resource
    private MenuMapper menuMapper;

    @Override
    public List<Menu> findMenu(Menu menu) {
        return menuMapper.selectMenu(menu);
    }

    @Override
    public PageInfo<Menu> findMenu(Menu menu, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Menu> list = menuMapper.selectMenu(menu);
        return new PageInfo<>(list);
    }

    @Override
    public int saveMenu(Menu menu) {
        return menuMapper.insertMenu(menu);
    }

    @Override
    public int modifyMenu(Menu menu) {
        return menuMapper.updateMenu(menu);
    }

    @Override
    public int removeMenuById(Integer id) {
        return menuMapper.deleteMenuById(id);
    }
}
